from django.db import models

# Create your models here.

class Post (models.Model):
  titel = models.CharField("Title", maxlength=100, unique=True)
  author = models.CharField(maxlength=20)
  pub_date = models.DateTimeField()
  text = models.TextField()

  # Gebraucht beim Fedd Generator
  def get_absolute_url (self):
    return "http://monkeystudio.org/blog/%s/" % self.id

  def __str__ (self):
    return self.titel
    
  class Admin:
    pass
    
  class Meta:
    ordering = ['-pub_date']
       
class Comment (models.Model):
  author = models.CharField("Author",maxlength=200)
  email  = models.EmailField()
  text   = models.TextField("Message")
  url    = models.CharField("Homepage", maxlength=200)
  pub_date = models.DateTimeField("Datum",'date published', auto_now_add=True)
  post = models.ForeignKey(Post)

  def __str__ (self):
    return self.author

  class Admin:
    pass
    
  class Meta:
    ordering = ['-pub_date']
    verbose_name = "Comment"
    verbose_name_plural = "Comments"
	
